import methodApi from './methodAPI'
import pageMeat from './methodAPI/pageMeats'
import './methodAPI/autoActivity'
// import { getSign } from './sing/index'
import { getUrlTabId } from './utils/tools'
// import './utils/db'
import listenerApis from './useIndexdDb/listenerApis'

chrome.storage.local.set({
  couplistDatas: ''
})
// setInterval(() => {
// const getsin = getSign('_bid=ecom_market_shop&appid=1&_=1733292732825&s=491723&msToken=xdRuqCFJK0woeivIk3FyQObzjqpMZvdhyJsABMSoWJdj67KjV9HmrCKxfjCN1mhNp5G5sC6flgymnAe7rsQIFpqp3r_ibtmLggYBDCJwVD8_P86oAktjoOqSQIJ4RxxIh9UnRZT4pCgJ4hkrFr31TUP-RcivBBstniWLV5l-6g%3D%3D&verifyFp=verify_m46gz291_4745b1a5_b0bf_c596_1248_f71d6d53311d&fp=verify_m46gz291_4745b1a5_b0bf_c596_1248_f71d6d53311d')
// setInterval(() => {
//   const eghgr = getSign('_bid=ecom_market_shop&appid=1&_=1733292732825&s=491723&msToken=xdRuqCFJK0woeivIk3FyQObzjqpMZvdhyJsABMSoWJdj67KjV9HmrCKxfjCN1mhNp5G5sC6flgymnAe7rsQIFpqp3r_ibtmLggYBDCJwVD8_P86oAktjoOqSQIJ4RxxIh9UnRZT4pCgJ4hkrFr31TUP-RcivBBstniWLV5l-6g%3D%3D&verifyFp=verify_m46gz291_4745b1a5_b0bf_c596_1248_f71d6d53311d&fp=verify_m46gz291_4745b1a5_b0bf_c596_1248_f71d6d53311d')
//   console.log('getSign', eghgr)
// }, 3000)
// console.log('getSign', getsin)


// }, 500);
chrome.extension.onMessage.addListener((request, sender, sendResponse) => {
  if (request.type_urs && request.type_urs === "wtbg") {
    var entry = methodApi[request.method || request.type]
    if (request.type_page && request.type_page === "pageMeat") {
      entry = pageMeat[request.method || request.type]
    }
    if (entry && entry.allow && entry.exec) {
      let ret = entry.exec(request, sender, sendResponse)
      return true
    } else {
      sendResponse(true)
    }
  }
  if (request.type_urs && request.type_urs === "tobgwt-coupon") {
    // console.log('一些content的动作', request)
    // chrome.storage.local.get(null, (result) => {
    //   console.log('result', result)
    // })
    listenerApis[request.method](request, sender, sendResponse)
  }
})
